import { View } from "../../../../mvc/core/View";
import { LayerManager } from "../../../manager/LayerManager";
import { Global } from "../../../../../com/gengine/global/Global";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GuildAnimalRewardPanel } from "./GuildAnimalRewardPanel";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { GuildUtil } from "../info/GuildUtil";
import { GuildAnimalType } from "../info/GuildAnimalType";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { SceneRange } from "../../../scene/map/SceneRange";
import { TweenMax } from "../../../../../com/greensock/TweenMax";
import { Quint } from "../../../../../com/greensock/easing/Quint";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class GuildAnimalShowView
    
    export  class GuildAnimalShowView extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.init();
            this.x = Global.stage.stageWidth - 500;
            this.y = 90;
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 300, 230, this);
            this._moveBtn = ObjCreate.createGButton("", 0, 0, 24, 22, this, "MoveBtn");
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMouseDownHandler);
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onMouseUpHandler);
            this._rightBtn = GlobalClass.getInstance("showBtn");
            this._rightBtn.x = 285;
            this._rightBtn.y = 11;
            this._rightBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onRightBtnClickHandler);
            this.addChild(this._rightBtn);
            this._titleTxt = ObjCreate.createGTextField(Language.getString(57510), 0, 0, 300, 20, this, GlobalStyle.windowTitle3);
            this._titleTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._descTxt = ObjCreate.createGTextField("", 10, 45, 260, 20, this);
            this._descTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._descTxt.wordWrap = true;
            this._descTxt.htmlText = Language.getString(57620);
            this._levelLabel = ObjCreate.createGTextField(Language.getString(57621), 10, 100, 220, 20, this, GlobalStyle.textFormat6);
            this._levelLabel.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._levelTxt = ObjCreate.createGTextField("", this._levelLabel.x + this._levelLabel.width, 100, 220, 20, this, GlobalStyle.textFormat6);
            this._titleBitmap = new Object /* flash.display.Bitmap */();
            this._titleBitmap.x = this._levelLabel.x + this._levelLabel.width;
            this._titleBitmap.y = 98;
            this.addChild(this._titleBitmap);
            this._rewardLabel = ObjCreate.createGTextField(Language.getString(57622), 10, 130, 220, 20, this, GlobalStyle.textFormat6);
            this._rewardLabel.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._rewardPanel = new GuildAnimalRewardPanel();
            this._rewardPanel.x = 0;
            this._rewardPanel.y = 150;
            this.addChild(this._rewardPanel);
            return;
        }

        public updateByType(arg1: int, arg2: int): void
        {
            var loc1=null;
            if (arg1 < 0) 
            {
                loc1 = GameDefConfig.instance.getGuildAnimalRewards(int(GuildUtil.getTypeByBossId(arg2) + 0));
                this._levelTxt.text = GuildAnimalType.getTypeName(-1);
            }
            else 
            {
                loc1 = GameDefConfig.instance.getGuildAnimalRewards(int(GuildUtil.getTypeByBossId(arg2) + arg1));
                this._levelTxt.text = "";
            }
            this._rewardPanel.updateList(loc1);
            this._bitmapName = GuildAnimalType.getBitmapNameByType(arg1);
            LoaderHelp.addResCallBack(ResFileConst.guildAnimal, this.updateTileBitmap);
            return;
        }

        public resize(): void
        {
            var loc1=SceneRange.display.width - 300 - 25;
            var loc2=180 + 20 * SceneRange.display.height / 1000;
            TweenMax.to(this, 0.2, {"x": loc1, "y": loc2, "ease": Quint.easeOut});
            return;
        }

        /* internal  */updateTileBitmap(): void
        {
            if (this._bitmapName) 
            {
                this._titleBitmap.bitmapData = GlobalClass.getBitmapData(this._bitmapName);
            }
            return;
        }

        /* internal  */onRightBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            this.resize();
            return;
        }

        /* internal  */onMouseDownHandler(arg1: Object /* flash.events.Event */): void
        {
            this.startDrag();
            return;
        }

        /* internal  */onMouseUpHandler(arg1: Object /* flash.events.Event */): void
        {
            this.stopDrag();
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskTrackShowOrHide, true));
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this.resize();
            Dispatcher.dispatchEvent(new DataEvent(EventName.TaskTrackShowOrHide, false));
            return;
        }

        /* internal */ /* var */_moveBtn: GButton;

        /* internal */ /* var */_rightBtn: Object /* flash.display.SimpleButton */;

        /* internal */ /* var */_titleTxt: GTextFiled;

        /* internal */ /* var */_descTxt: GTextFiled;

        /* internal */ /* var */_levelLabel: GTextFiled;

        /* internal */ /* var */_levelTxt: GTextFiled;

        /* internal */ /* var */_titleBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_rewardLabel: GTextFiled;

        /* internal */ /* var */_rewardPanel: GuildAnimalRewardPanel;

        /* internal */ /* var */_bitmapName: string;
    }
